package com.huike.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import javax.servlet.http.HttpServletResponse;

public class JsonUtils {
    public static void jsonArray(Object jsonArray, HttpServletResponse response) {
        response.setContentType("text/html;charset=utf-8");
        try {
            if (jsonArray instanceof String) {
                response.getWriter().write(JSON.parse(jsonArray.toString().replaceAll("\\s", "</br>")).toString());
            } else {
                response.getWriter().write(JSONArray.toJSONString(jsonArray).replaceAll("\\s", "</br>"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
